package edu.se.jai.gameservice.dto;

import lombok.Data;

/**
 * 操作结果封装类
 * 
 * 统一的结果封装，用于game-service内部业务逻辑返回
 */
@Data
public class Result<T> {
    private boolean success;
    private String errorMessage;
    private T data;
    
    public boolean isSuccess() {
        return success;
    }
    
    public boolean isFailure() {
        return !success;
    }
    
    public static <T> Result<T> success(T data) {
        Result<T> result = new Result<>();
        result.success = true;
        result.data = data;
        return result;
    }
    
    public static <T> Result<T> success() {
        Result<T> result = new Result<>();
        result.success = true;
        return result;
    }
    
    public static <T> Result<T> failure(String errorMessage) {
        Result<T> result = new Result<>();
        result.success = false;
        result.errorMessage = errorMessage;
        return result;
    }
}

